# Ollama  不需要 api_key

import requests
import json

question = input("请输入问题：") or "20字介绍北京"

url = "http://localhost:11434/v1/chat/completions"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer ollama"
}

data = {
    "model": "qwen2.5:3b",
    "messages": [
        {"role": "user", "content": question}
    ]
}

response = requests.post(url, headers=headers, data=json.dumps(data))

answer = response.json()['choices'][0]['message']['content']

print(answer)        